package com.example.event_resource_java.commons.util;

import java.util.Random;
import java.util.UUID;

/**
 * <pre>
 *
 * </pre>
 * <small> 2019-05-09 16:40 | Aron</small>
 */
public abstract class UUIDUtils {

    public static String get(boolean isPureStr) {
        String result = UUID.randomUUID().toString();
        if (isPureStr) {
            result = result.replaceAll("-", "");
        }
        return result;
    }

    public static String get() {
        return get(true);
    }


    public static long uniqId() {
        Random random = new Random();
        String nanoRandom = System.nanoTime() + "" + random.nextInt(99999);
        int hash = Math.abs(UUID.randomUUID().hashCode());
        int needAdd = 19 - String.valueOf(hash).length() + 1;
        return Long.valueOf(hash + "" + nanoRandom.substring(needAdd));
    }



}
